package cn.tedu.spring.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试类
 */
public class TestUser {
    public static void main(String[] args) {
        /*
            1.Spring Framework创建对象,放入IoC容器中;
            2.从IoC容器中获取对象;
            3.调用run()方法进行测试;
         */
        ApplicationContext context = new AnnotationConfigApplicationContext("cn.tedu.spring.example");
//        User user = context.getBean(User.class);
        User user = context.getBean(User.class);
        user.run();

//        ApplicationContext context1 = new ClassPathXmlApplicationContext("bean.xml");
//        User user1 = context1.getBean(User.class);
//        user1.run();
    }
}












